/**
 * @param {number} x
 * @return {boolean}
 */


let ONES = {
  "negative": -1, "zero": 0, "one": 1, "two": 2, "three": 3, "four": 4, "five": 5, "six": 6, "seven": 7, "eight": 8, "nine": 9, "ten": 10, "eleven": 11, "twelve": 12, "thirteen": 13, "fourteen": 14, "fifteen": 15, "sixteen": 16, "seventeen": 17, "eighteen": 18, "nineteen": 19
}
let TENS = { "twenty": 20, "thirty": 30, "forty": 40, "fifty": 50, "sixty": 60, "seventy": 70, "eighty": 80, "ninety": 90 }
// , "hundred": 100, "thousand": 1000, "million": 1000000 

function parseInt(string) {
  let number = []
  strs = string.split(' and ').join(' ').split('-').join(' ').split(' ')
  for (token of strs) {
    if (token in ONES) {
      number.push(ONES[token])
    } else if (token in TENS) {
      number.push(TENS[token])
    } else if (token == 'hundred') {
      number[number.length - 1] *= 100
    } else if (token == 'thousand') {
      for (item in number) { number[item] *= 1000 }
    } else if (token == 'million') {
      for (item in number) { number[item] *= 1000000 }
    }
  }
  return eval(number.join('+'))
}
console.log(parseInt('seven hundred eighty-three thousand nine hundred and nineteen'))
// 783919

